<template>
  <div class="activityNote">
    <div class="product">
      <ul class="show_ul">
        <li
          v-for="activity in activityNote"
          :key="activity.gameTitleId"
          :to="{name:'Note',params:{id:activity.noteId}}"
        >
          <div class="u">
            <span class="userImg">
              <img :src="'/api/upload/' + activity.userImg" alt />
            </span>
            <div class="name">
              <span>{{activity.userName}}</span>
              <div class="noteTime">{{formateDate(activity.noteTime)}}</div>
            </div>
          </div>
          <span class="noteId">{{activity.noteId}}</span>
          <router-link class="c" :to="{name:'Note',params:{id:activity.noteId}}">
            <div class="show_t">
              <span>{{activity.noteTitle}}</span>
            </div>
            <br />
            <div class="show_img">
              <i>
                <span>
                  <img :src="'/api/upload/' + activity.noteImg1" alt />
                </span>
              </i>
              <i>
                <span>
                  <img :src="'/api/upload/' + activity.noteImg2" alt />
                </span>
              </i>
            </div>
          </router-link>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      queryId: -1,
      activityNote: []
    };
  },
  watch: {
    $route(to, from) {
      this.$router.go(0);
    }
  },
  created() {
    this.queryId = this.$route.params.id;
    this.$axios
      .get("/api/gameTitle/getGame", { params: { gameTitleId: this.queryId } })
      .then(res => {
        // console.log('res:',res.data.data)
        this.activityNote = res.data.data;
        console.log(this.activityNote);
      })
      .catch(err => {
        console.log("err:", err);
      });
  },
  methods: {
    // 时间格式转换
    formateDate: function(datetime) {
      function addDateZero(num) {
        return num < 10 ? "0" + num : num;
      }
      let d = new Date(datetime);
      let formatdatetime =
        d.getFullYear() +
        "-" +
        addDateZero(d.getMonth() + 1) +
        "-" +
        addDateZero(d.getDate())+' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
      
      return formatdatetime;
    }
  }
};
</script>
<style lang="css" scoped>
@import "../../css/activity.css";
</style>